//
//  LFNavViewController.swift
//  1604_LimitFree
//
//  Created by 千锋 on 16/9/26.
//  Copyright © 2016年 Mabin. All rights reserved.
//

import UIKit

class LFNavViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        createMyNav()
    }
    
    func createMyNav()
    {
        
    }
    
    //标题文字
    func addnavTitle(title : String)
    {
        let label = UILabel.createlabelFrame(CGRectMake(0, 0, 215, 44), title: title, textAlignment: NSTextAlignment.Center)
        label.font = UIFont.boldSystemFontOfSize(25)
        label.textColor = UIColor(red: 58.0 / 255.0, green: 95.0 / 255.0, blue: 145 / 255.0, alpha: 1.0)
        self.navigationItem.titleView = label
    }
    
    //导航按钮
    func addNavBarbutton(title : String, target:AnyObject?,action : Selector, isLeft : Bool)
    {
        addNavBarbutton(title, target: target, action: action, isLeft: isLeft, imageName: "buttonbar_action")
    }
    
 
    //添加返回按钮
    private func addNavBarbutton(title : String, target:AnyObject?,action : Selector, isLeft : Bool, imageName : String)
    {
        let button = UIButton.createBtn(CGRectMake(0, 0, 60, 36), title: title, bgImageName: imageName, target: target, action: action)
        let barbutton = UIBarButtonItem(customView: button)
        if isLeft
        {
            navigationItem.leftBarButtonItem = barbutton
        }
        else
        {
            navigationItem.rightBarButtonItem = barbutton
        }
    }
    
    //添加返回按钮
    func addBackButton()
    {
       addNavBarbutton("返回", target: self, action: "backAction", isLeft: true, imageName: "buttonbar_back")
    }
    
    func backAction()
    {
        self.navigationController?.popToRootViewControllerAnimated(true)
    }
    
    
    
    
}
